package droideep.library.base.mvp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

/**
 * @author bri
 * @date 15-5-11.
 */
public abstract class BasePresenterActivity<V extends Vu> extends AppCompatActivity {
    protected V vu;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
            vu = getVuClass().newInstance();
            vu.init(getLayoutInflater(), null);
            setContentView(vu.getView());
            onBindVu();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

    }

    @Override
    protected void onDestroy() {
        onDestoryVu();
        vu = null;
        super.onDestroy();
    }

    protected abstract Class<V> getVuClass();

    protected void onBindVu() {
    }

    protected void onDestoryVu() {

    }
}
